program calcAvg
  
  CalculateAverage()
    var n, sum, amount, value: int
  begin
    n:=0
    sum:=0
    Write(in "calulate average:")
    Write(in "amount of values >")
    Read(out amount)
    Write(in "")
    while amount>0 do
      Read(out value)
      n := n + 1
      sum := sum + value
      amount := amount - 1
    end -- while
    if n > 0 then
      Write(in sum/n)
    else -- n = 0
      Write(in "no average")
    end
  end CalculateAverage
  
begin
  -! "test"
  CalculateAverage()
  Read()
end